<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2017/9/11
  Time: 17:25
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@include file="../common/include.jsp" %>
<html>
<head>
    <title>Title</title>
    <script>
        function changeStatus() {
            var demandType = $("#demandType").val();
            $("#status").val(0);
            var myDem = $("#myDem").val();


            if (demandType == 0) {
                $("#searchForm").attr("action", "getAllUpdDemand.html?conditions['status']=1");
                demandType = "全部"
            }
//            if (demandType == 1) {
//                $("#searchForm").attr("action", "allBugList.html?conditions['status']=1");
//                demandType = "BUG"
//            }
//
//            if (demandType == 2) {
//                $("#searchForm").attr("action", "demandList.html?conditions['status']=1");
//                demandType = "需求"
//            }
//
//            if (demandType == 3) {
//                $("#searchForm").attr("action", "opertionList.html?conditions['status']=1");
//                demandType = "操作"
//            }
            $("#searchForm").submit();
        }



        function queryDemand() {
            var demandType = $("#demandType").val();
            var myDem = $("#myDem").val();


            if (demandType == 0) {
                $("#searchForm").attr("action", "getAllUpdDemand.html?conditions['status']=1");
                demandType = "全部"
            }
//            if (demandType == 1) {
//                $("#searchForm").attr("action", "allBugList.html?conditions['status']=1");
//                demandType = "BUG"
//            }
//
//            if (demandType == 2) {
//                $("#searchForm").attr("action", "demandList.html?conditions['status']=1");
//                demandType = "需求"
//            }
//
//            if (demandType == 3) {
//                $("#searchForm").attr("action", "opertionList.html?conditions['status']=1");
//                demandType = "操作"
//            }
            $("#searchForm").submit();
        }



        var param = "";
        $(function () {

            $("#subBtn").click(function () {
                window.location = "goAddDemandSource.html";
            });

            var index = 0;
            //双击tr弹出页面
            $("#cusTable tr td").dblclick(function () {

                var demandType = $(this).parent('tr').attr('demandType');
                var content = "";
                if (demandType == 1) {
                    content = 'bugDetail.html?bugId=';
                    demandType = "BUG"
                }

                if (demandType == 2) {
                    content = 'demandDetail.html?demandId=';
                    demandType = "需求"
                }

                if (demandType == 3) {
                    content = 'operationDetail.html?id=';
                    demandType = "操作"
                }
                //alert($(this).html());
                //alert($(this).attr('custId'));
                //alert($(this).parent('tr').attr('custId'));
                var title = demandType + "-" + $(this).parent('tr').attr('statusText');
                index = layer.open({
                    type: 2,
                    title: title,
                    skin: 'ilayui-layer-rm', //加上边框
                    area: ['90%', '90%'], //宽高
                    content: content + $(this).parent('tr').attr('id'),
//                end: function () {
//                    location.reload();
//                }
                });
            });
        });

        function clearForms() {
            $('#createName').val("");
            $('#demandProduct').val("0");
            $('#status').val("0");
            $('#beginTime').val("");
            $('#detail').val("");
            $('#endTime').val("");
            $('#joinName').val("");
            $('#currentPrincipal').val("");
            $('#isSuspend').val("0");
            $('#feedbackName').val("");
            $('#feedbackCity').val("");
        }
    </script>
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content  animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox ">
                <div class="ibox-content">

                    <div class="jqGrid_wrapper">
                        <div class="ui-jqgrid " id="gbox_table_list_2" dir="ltr">
                            <div class="ui-jqgrid-view table-responsive" role="grid" id="gview_table_list_2"
                            >


                                <form role="form" class="form-inline" style="margin-bottom: 10px" id="searchForm"
                                      method="post" action="getAllUpdDemand.html">

                                    <input type="hidden" id="myDem" value="${myDem}">
                                    <div class="form-group">
                                        <input name="conditions['title']" id="title"
                                               placeholder="标题"
                                               type="text" size="8" value="${pages.conditions.title}"
                                               class="form-control">&nbsp;&nbsp;&nbsp;
                                        <input type="text" name="conditions['detail']" placeholder="问题描述"
                                               value="${pages.conditions.detail}" size="8"
                                               id="detail" class="form-control">&nbsp;&nbsp;&nbsp;
                                        <select id="demandProduct" name="conditions['demandProduct']"
                                                class="form-control"
                                                required="" aria-required="true">
                                            <option value="0"
                                                    <c:if test="${pages.conditions.demandProduct == 0}">selected</c:if>>
                                                问题产品
                                            </option>
                                            <c:forEach items="${productList}" var="product">
                                                <option
                                                        <c:if test="${pages.conditions.demandProduct == product.id}">selected</c:if>
                                                        value="${product.id}">${product.product_name}</option>
                                            </c:forEach>
                                        </select>
                                    </div>
                                    <input name="conditions['feedbackName']" id="feedbackName"
                                           placeholder="反馈人"
                                           type="text" size="8" value="${pages.conditions.feedbackName}"
                                           class="form-control">&nbsp;&nbsp;


                                    <div class="form-group" style="text-align: left;margin-top: 5px">


                                        <button type="button" onclick="queryDemand()"
                                                class="btn btn-primary">搜索
                                        </button>&nbsp;&nbsp;&nbsp;
                                        <button type="button" id="subBtn" class="btn btn-primary">
                                            问题提交
                                        </button>
                                        &nbsp;&nbsp;&nbsp;<input type="button" onclick="clearForms()" id="resetBut"
                                                                 value="重置" class="btn btn-reset">

                                    </div>
                                    <div style="float: right;margin-top: 15px;margin-right: 15px">
                                        总记录：${pages.totalRecords}</div>

                                </form>


                                <div class="ui-jqgrid-bdiv">
                                    <div style="position:relative;">
                                        <div></div>
                                        <table id="cusTable"
                                               class="ui-jqgrid-btable ui-common-table table table-bordered"
                                        >
                                            <tbody>
                                            <tr role="row" style="background: #F5F5F5;">
                                                <td>类型
                                                </td>
												<td>编号
                                                </td>
                                                <td>标题
                                                <td>描述</td>
                                                </td>
                                                <td>反馈人
                                                </td>

                                                <td>录入人
                                                </td>

                                                <td style="width: 15%">录入时间
                                                </td>


                                                <td>
                                                    状态
                                                </td>
                                                <td>责任人
                                                </td>
                                                <td>操作
                                                </td>
                                            </tr>


                                            <c:forEach items="${pages.pageDatas}" var="demand">
                                                <tr role="row" tabindex="-1" id="${demand.id}"
                                                    statusText="${demand.status_text}" demandType="${demand.demandType}"
                                                    class="jqgrow ui-row-ltr">
<td>
                                                        <c:if test="${demand.demandType ==1}"><span
                                                                > <i class="fa fa-exclamation-triangle"
                                                                                          style="width:30px;text-align:center;color:#f74a13"></i>BUG</span></c:if>
                                                        <c:if test="${demand.demandType ==2}"><span
                                                                ><i class="fa fa-plus-circle"
                                                                                         style="width:30px;text-align:center;color:#f8ac59"></i>需求</span></c:if>
                                                        <c:if test="${demand.demandType ==3}"><span><i class="fa fa-cog"
                                                                                         style="width:30px;text-align:center;color:#1ab394"></i>操作</span></c:if>
                                                    </td>

													<td>
                                                            ${demand.id}
                                                    </td>
                                                    <td>
                                                            ${demand.title}
                                                    </td>
                                                    <td>
                                                            ${fn:length(demand.detail) > 20 ? fn:substring(demand.detail,0,20) : demand.detail}

                                                    </td>
                                                    <td>
                                                            ${demand.feedback_name}
                                                    </td>

                                                    <td>
                                                            ${demand.create_name}
                                                    </td>
                                                    <td>
                                                            ${demand.create_time}
                                                    </td>


                                                    <td>
                                                        <c:if test="${demand.is_suspend == 2}">已暂停</c:if>
                                                        <c:if test="${demand.is_suspend != 2}"> ${demand.status_text}</c:if>
                                                    </td>
                                                    <td>

                                                        <c:if test="${demand.status == 7}">总监</c:if>
                                                        <c:if test="${demand.status != 7 && demand.demandType!=3 }">${demand.current_principal}</c:if>
                                                        <c:if test="${demand.demandType == 3}">${demand.create_name}</c:if>
                                                    </td>

                                                    <td>


                                                        <!--操作转换其他问题类型按钮 -->
                                                            <a id="updBtn"
                                                                demandType="${demand.demandType}"
                                                                demId="${demand.id}" title="编辑"
                                                                class="handleicon" type="button">
                                                                <i class="fa fa-pencil-square-o"></i>
                                                            </a>


                                                        <a id="delBtn"
                                                                demandType="${demand.demandType}"
                                                                demId="${demand.id}" title="删除"
                                                                class="handleicon" type="button">
                                                            <i class="fa fa-trash-o"></i>
                                                        </a>
                                                    </td>
                                                </tr>

                                            </c:forEach>


                                            </tbody>
                                        </table>
                                        <c:if test="${pages.totalPages>1 }">
                                            <page:pager pageSize="${pages.pageSize}" currPage="${pages.currPage}"
                                                        totalRecords="${pages.totalRecords}"
                                                        url="${pageContext.request.contextPath}/${action}?conditions['demandProduct']=${pages.conditions.demandProduct }&conditions['createName']=${pages.conditions.createName }&conditions['status']=${1 }&conditions['beginTime']=${pages.conditions.beginTime }&conditions['endTime']=${pages.conditions.endTime }&conditions['joinName']=${pages.conditions.joinName }&conditions['currentPrincipal']=${pages.conditions.currentPrincipal }&conditions['detail']=${pages.conditions.detail }&conditions['demandType']=${pages.conditions.demandType }&conditions['isSuspend']=${pages.conditions.isSuspend }&conditions['feedbackCity']=${pages.conditions.feedbackCity }&conditions['feedbackName']=${pages.conditions.feedbackName }&conditions['title']=${pages.conditions.title }"/>

                                        </c:if>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

</body>

<script>
 //enter搜索
    $('body').bind('keypress', function (event) {
       if (event.keyCode == "13") {
        queryDemand()
       }
      })
    //编辑按钮
    $("[id=updBtn]").click(function () {

        var title = "编辑提交";

        var action = "allUpdDemand.html";

        //alert($(this).html());
        //alert($(this).attr('status'));
        //alert($(this).attr('demand_id'));
        //alert($(this).parent('tr').attr('custId'));
        index = layer.open({
            type: 2,
            title: title,
            skin: 'ilayui-layer-rm', //加上边框
            area: ['90%', '90%'], //宽高
            content: action + '?id=' + $(this).attr('demId')+"&demandType="+$(this).attr('demandType'),
            end: function () {
                location.reload();
            }
        });
    });



    $("[id=delBtn]").click(function () {
        var id = $(this).attr('demId');
        var demandType = $(this).attr('demandType');
        var title = "确定删除？";

        var obj = $(this);
        layer.msg(title, {
            time: 0 //不自动关闭
            , btn: ['确定', '取消']
            , yes: function (index) {


                var args = {
                    "opId": id,
                    "demandType": demandType
                }

                var url = "delUntreatedDemand.html";

                //加载进度条
                layer.load(2, {
                    shade: [0.2, '#999999'] //0.1透明度的白色背景
                });
                $.post(url, args, function (data) {
                    data = jQuery.parseJSON(data);
                    //保存成功
                    if (data.code == 1) {
                        window.location.reload();
                        layer.closeAll('loading');
                    } else {
                        //失败
                        layer.alert(data.msg);
                        layer.closeAll('loading');
                    }
                });
                layer.close(index);

            }
        });
    });



</script>
</html>
